let app = getApp();

const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'

Page({
  data: {
    tabActive: 0,
    onAudioBottomCount: 1,
    onBookshelfBottomCount: 2,
    isLittleDrawingVisible: false, // 播放最小画
    kitapCon: '', // 最小画书籍信息
    chapterName: '', // 最小画章节名
  },

  onLoad(options) {
    
  },

  onShow() {
    this.LittleDrawingVisible(); // 监听播放最小画
  },

  onHide() {
    
  },

  onUnload() {
    
  },

  // 监听播放最小画
  LittleDrawingVisible() {
    this.setData({ 
      isLittleDrawingVisible: app.globalData.isLittleDrawingVisible,
      kitapCon: app.globalData.kitapCon,
      chapterName: app.globalData.chapterName
    })
  },
  
  onChangeTab(e) {
    wx.pageScrollTo({
        scrollTop: 0,
        duration: 0
    })
    let item, index
    item = e.detail.item
    index = e.detail.index
    
    this.setData({ tabActive: index })
  },

  onPullDownMethod(value) {
  if (value == true) {
      this.noMoreMethod(true)
    }
  },

  onReachBottom() {
    if (this.data.tabActive == 1) {
        this.setData({ onAudioBottomCount: this.data.onAudioBottomCount += 1 })
    }else if (this.data.tabActive == 2) {
      this.setData({ onBookshelfBottomCount: this.data.onBookshelfBottomCount += 1 })
    }
  },

  refreshIndexData() {
    console.log('刷新Index页面数据');
    // 这里可调用接口获取最新数据，或重置页面状态
  },

  // 转发
  onShareAppMessage() {
    return {
      title: 'قىيات ئاۋازلىق ئەسەر',
      path: '/pages/index/index',
      imageUrl: 'https://mmecoa.qpic.cn/sz_mmecoa_png/iauAIibMdU78thJHXKBcIfYLNA6zH3pbFllMLlSibhVriaGwtS0bM1tLLyz6OSlQ74icF6c4Yic4icLokYGvb2jXnY8bA/640?wx_fmt=png&amp;from=appmsg'
    };
  }
})
